package com.fw.ui.view.settings.globalsetting.event;

import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.fw.ui.util.UICommonUtils;
import com.fw.ui.view.event.AbstractButtonClickListener;
import com.fw.ui.view.settings.globalsetting.EditGlobalSettingView;
import com.vaadin.ui.Button.ClickEvent;

@Component
@Scope(SCOPE_PROTOTYPE)
public class EditGlobalSettingClearButtonClickListener extends AbstractButtonClickListener {

    private static final long serialVersionUID = 1L;

    @Autowired
    private UICommonUtils uiCommonUtils;

    @Override
    public Map<String, Object> click(ClickEvent event) throws Exception {
	EditGlobalSettingView editGlobalSettingView = (EditGlobalSettingView) this.getBasedComponent();

	uiCommonUtils.setValueUIComponent(editGlobalSettingView.getTxtPayAtAllServiceInquiryPeriod(), "");
	uiCommonUtils.setValueUIComponent(editGlobalSettingView.getTxtTransactionReportMaximumPeriodSearchAeonUser(), "");
	uiCommonUtils.setValueUIComponent(editGlobalSettingView.getTxtTransactionReportMaximumPeriodSearchMerchantUser(), "");
	uiCommonUtils.setValueUIComponent(editGlobalSettingView.getTxtAuditLogMaximumPeriodSearch(), "");
	uiCommonUtils.clearAllUIComponentNoInputFieldWithPrefix(editGlobalSettingView);

	Map<String, Object> result = new HashMap<String, Object>();
	return result;
    }

    @Override
    public boolean validate(ClickEvent event) {
	return true;
    }

}
